<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Listeprojetsregional extends Application_Model_ModelAbstract
{

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idprojetsregional;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idprojetregional;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Titre;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_Datedebut;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_Datefin;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Cout;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Coutreel;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Etatavancement;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Description;


    /**
     * Parent relation fk_listeprojetsregional_projetregional1
     *
     * @var Application_Model_Projetregional
     */
    protected $_Projetregional;


    /**
     * Dependent relation fk_feuilleprojet_listeprojetsregional1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Feuilleprojet
     */
    protected $_Feuilleprojet;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idprojetsregional'=>'Idprojetsregional',
            'idprojetregional'=>'Idprojetregional',
            'titre'=>'Titre',
            'datedebut'=>'Datedebut',
            'datefin'=>'Datefin',
            'cout'=>'Cout',
            'coutreel'=>'Coutreel',
            'etatavancement'=>'Etatavancement',
            'description'=>'Description',
        ));

        $this->setParentList(array(
            'FkListeprojetsregionalProjetregional1'=> array(
                    'property' => 'Projetregional',
                    'table_name' => 'Projetregional',
                ),
        ));

        $this->setDependentList(array(
            'FkFeuilleprojetListeprojetsregional1' => array(
                    'property' => 'Feuilleprojet',
                    'table_name' => 'Feuilleprojet',
                ),
        ));
    }

    /**
     * Sets column idprojetsregional
     *
     * @param string $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setIdprojetsregional($data)
    {
        $this->_Idprojetsregional = $data;
        return $this;
    }

    /**
     * Gets column idprojetsregional
     *
     * @return string
     */
    public function getIdprojetsregional()
    {
        return $this->_Idprojetsregional;
    }

    /**
     * Sets column idprojetregional
     *
     * @param int $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setIdprojetregional($data)
    {
        $this->_Idprojetregional = $data;
        return $this;
    }

    /**
     * Gets column idprojetregional
     *
     * @return int
     */
    public function getIdprojetregional()
    {
        return $this->_Idprojetregional;
    }

    /**
     * Sets column titre
     *
     * @param text $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setTitre($data)
    {
        $this->_Titre = $data;
        return $this;
    }

    /**
     * Gets column titre
     *
     * @return text
     */
    public function getTitre()
    {
        return $this->_Titre;
    }

    /**
     * Sets column datedebut
     *
     * @param date $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setDatedebut($data)
    {
        $this->_Datedebut = $data;
        return $this;
    }

    /**
     * Gets column datedebut
     *
     * @return date
     */
    public function getDatedebut()
    {
        return $this->_Datedebut;
    }

    /**
     * Sets column datefin
     *
     * @param date $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setDatefin($data)
    {
        $this->_Datefin = $data;
        return $this;
    }

    /**
     * Gets column datefin
     *
     * @return date
     */
    public function getDatefin()
    {
        return $this->_Datefin;
    }

    /**
     * Sets column cout
     *
     * @param string $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setCout($data)
    {
        $this->_Cout = $data;
        return $this;
    }

    /**
     * Gets column cout
     *
     * @return string
     */
    public function getCout()
    {
        return $this->_Cout;
    }

    /**
     * Sets column coutreel
     *
     * @param string $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setCoutreel($data)
    {
        $this->_Coutreel = $data;
        return $this;
    }

    /**
     * Gets column coutreel
     *
     * @return string
     */
    public function getCoutreel()
    {
        return $this->_Coutreel;
    }

    /**
     * Sets column etatavancement
     *
     * @param string $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setEtatavancement($data)
    {
        $this->_Etatavancement = $data;
        return $this;
    }

    /**
     * Gets column etatavancement
     *
     * @return string
     */
    public function getEtatavancement()
    {
        return $this->_Etatavancement;
    }

    /**
     * Sets column description
     *
     * @param text $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets parent relation Idprojetregional
     *
     * @param Application_Model_Projetregional $data
     * @return Application_Model_Listeprojetsregional
     */
    public function setProjetregional(Application_Model_Projetregional $data)
    {
        $this->_Projetregional = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idprojetregional'];
        }

        $this->setIdprojetregional($primary_key);

        return $this;
    }

    /**
     * Gets parent Idprojetregional
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Projetregional
     */
    public function getProjetregional($load = true)
    {
        if ($this->_Projetregional === null && $load) {
            $this->getMapper()->loadRelated('FkListeprojetsregionalProjetregional1', $this);
        }

        return $this->_Projetregional;
    }

    /**
     * Sets dependent relations fk_feuilleprojet_listeprojetsregional1
     *
     * @param array $data An array of Application_Model_Feuilleprojet
     * @return Application_Model_Listeprojetsregional
     */
    public function setFeuilleprojet(array $data)
    {
        $this->_Feuilleprojet = array();

        foreach ($data as $object) {
            $this->addFeuilleprojet($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_feuilleprojet_listeprojetsregional1
     *
     * @param Application_Model_Feuilleprojet $data
     * @return Application_Model_Listeprojetsregional
     */
    public function addFeuilleprojet(Application_Model_Feuilleprojet $data)
    {
        $this->_Feuilleprojet[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_feuilleprojet_listeprojetsregional1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Feuilleprojet
     */
    public function getFeuilleprojet($load = true)
    {
        if ($this->_Feuilleprojet === null && $load) {
            $this->getMapper()->loadRelated('FkFeuilleprojetListeprojetsregional1', $this);
        }

        return $this->_Feuilleprojet;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Listeprojetsregional
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Listeprojetsregional());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Listeprojetsregional::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdprojetsregional() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idprojetsregional = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdprojetsregional()));
    }
}
